using System;
using System.Collections.Generic;
using System.IO;
using SQLRunnerLib.RunnableItems;

namespace SQLRunner.gui
{
    public delegate void ModelChangedDelegate(ScriptsModel sender, EventArgs e);

    public class ScriptsModel
    {

        private readonly ProjectManager _projectManager;

        public ScriptsModel()
        {
            // TODO: check if an empty roof folder is correct
            _projectManager = new ProjectManager(string.Empty);
        }

        #region IScriptsModel Members

        public event ModelChangedDelegate ModelChange;

        public ProjectManager ProjectMgr
        {
            get { return _projectManager; }
        }

        public void ModelChanged(EventArgs e)
        {
            if (ModelChange != null)
            {
                ModelChange(this, e);
            }
        }

        public void AddDir(DirectoryInfo dir)
        {
            // TODO: How to inform that folder already was added to the project
            if ( _projectManager.AddFolder(dir, null) != null) 
                ModelChanged(new EventArgs());
        }


        #endregion
    }
}
